Skip to content

feat: add message deletion from a session thread (#287)#395

Merged
imDarshanGK merged 4 commits into
imDarshanGK:mainfrom
anandsundaramoorthysa:feat/287-delete-message
Jun 15, 2026
Merged

feat: add message deletion from a session thread (#287)#395
imDarshanGK merged 4 commits into
imDarshanGK:mainfrom
anandsundaramoorthysa:feat/287-delete-message

Conversation

@anandsundaramoorthysa

Copy link
Copy Markdown
Contributor

Description

Adds the ability to delete a single message from a session thread. Previously the app could only "clear all messages" in a session — there was no way to remove one message.

Closes #287

Changes

Backend

  • db_service.delete_message(session_id, message_id) — session-scoped delete (a message can only be removed from its own thread) that also decrements the session's message_count (clamped at 0).
  • get_messages_full now returns each message's id, so the client can target a specific message (it previously omitted the id).
  • New route: DELETE /api/sessions/{session_id}/messages/{message_id}404 when the message doesn't exist in that session.
  • Tests: test_delete_single_message and test_delete_message_not_found.

Frontend

  • api.deleteMessage(sessionId, messageId).
  • Use the real message id from the backend instead of the array index (so deletes target the correct row).
  • ChatWindow: a delete control on every message (user and assistant) with a lightweight inline "Delete? Yes / No" confirm (no window.confirm, consistent with the project's move away from native dialogs), and optimistic removal for instant feedback.

Verification

  • Full pytest suite passes — 73 tests (including the 2 new ones).
  • Live end-to-end check: seeded a session with 3 messages, deleted one from the UI → it was removed from the thread and from the database, and the sidebar message count stayed in sync (3 → 2). The remaining messages and other sessions were untouched.

Notes

  • The delete is scoped by session_id, so a crafted request can't delete another session's message.
  • Optimistic UI removal means freshly-streamed (not-yet-persisted) messages are also removed cleanly from the view.

Adds the ability to delete a single message from a chat thread (previously
only "clear all messages" existed).

Backend:
- db_service.delete_message(session_id, message_id): session-scoped delete
  that also decrements the session's message_count (clamped at 0)
- get_messages_full now returns each message's id so the client can target
  a specific message
- DELETE /api/sessions/{session_id}/messages/{message_id} route (404 when
  the message doesn't exist in the session)
- Tests: test_delete_single_message and test_delete_message_not_found

Frontend:
- api.deleteMessage(sessionId, messageId)
- Use the real message id from the backend (instead of the array index)
- ChatWindow: a delete control on each message with a lightweight inline
  "Delete? Yes/No" confirm (no window.confirm), with optimistic removal

Verified: full pytest suite passes (73 tests) and a live end-to-end check
(delete a message in the UI -> removed from the thread and the DB, with the
sidebar count kept in sync).
@vercel

vercel Bot commented Jun 13, 2026

Copy link
Copy Markdown

@anandsundaramoorthysa is attempting to deploy a commit to the Darshan's projects Team on Vercel.

A member of the Team first needs to authorize it.

…sage

# Conflicts:
#	frontend/src/components/ChatWindow.jsx
@anandsundaramoorthysa

Copy link
Copy Markdown
Contributor Author

Resolved the merge conflict with main (in efadf90). It was in ChatWindow.jsx between this PR's per-message delete control and the recent dark-mode contrast fix for the "You" label — I kept both (the delete control + text-gray-400). Re-ran the backend tests (delete-message + the new clone-session tests all pass). Ready for review.

@anandsundaramoorthysa

Copy link
Copy Markdown
Contributor Author

@imDarshanGK this is conflict-free and green now (tests passing) — could you please review it when you get a chance? Happy to address any feedback. Thanks!

@imDarshanGK imDarshanGK added SSoC26 Part of Social Summer of Code 2026 Medium Feature or backend work with moderate scope labels Jun 15, 2026
@imDarshanGK

Copy link
Copy Markdown
Owner

@anandsundaramoorthysa resolve conflicts

…sage

# Conflicts:
#	frontend/src/App.jsx
#	frontend/src/components/ChatWindow.jsx
@anandsundaramoorthysa

Copy link
Copy Markdown
Contributor Author

@imDarshanGK conflicts resolved (in c208672). The clash was between this PR's per-message delete control and the new Stop-Generation onStop prop — I kept both (onDeleteMessage + onStop on ChatWindow). Verified after merge: ruff clean, backend 81 tests pass, and the frontend builds successfully. Ready for review!

@imDarshanGK imDarshanGK merged commit 65e70e3 into imDarshanGK:main Jun 15, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Medium Feature or backend work with moderate scope SSoC26 Part of Social Summer of Code 2026

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add message deletion from a session thread

2 participants